Skip to content

Conversation

cutalion
Copy link

It turned out that pluralization in i81n backend does not work, because :count is stripped out from provided options.

  en:
    foo:
      one: %{count} foo
      other: %{count} foos
  I18n.t(:foo, count: 1) #=> 1 foo
  I18n.t(:foo, count: 1) #=> 2 foos

I suggest to pass all options down to I18n.t method. Already tested this in production with dry-validation.

Not sure that the meta in case of pluralization should be returned when no :count provided, because meta and template are the same in that case. Is it ok?

template, meta = messages[:apples, path: :path]

expect(meta).to eql({
  one: "single apple",
  other: "%{count} apples"
})

expect(template.()).to eql({
  one: "single apple",
  other: "%{count} apples"
})

Pass all provided options down to I18n.t method. It will use `:count`
option to pluralize the message.

  en:
    foo:
      one: %{count} foo
      other: %{count} foos

  I18n.t(:foo, count: 1) #=> 1 foo
  I18n.t(:foo, count: 1) #=> 2 foos
@cutalion cutalion force-pushed the feature/support-pluralization branch from 1f8a52f to 20f396c Compare August 25, 2023 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant